package graphics;


import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JButton;
import java.lang.Override;
import java.awt.print.PageFormat;
import java.awt.print.PrinterException;

import javax.swing.JPanel;

public class PrintPreviewJPanel extends JPanel {
	OrdineJPanel bj;
	//BillViewJPanel bjv;
	JButton printButton;
	
	public PrintPreviewJPanel(OrdineJPanel b)
	{
		this.setSize(800, 600);
		this.setVisible(true);
		bj = b;
		//bjv = null;
		printButton = b.copyjButtonPrint();
		printButton.setLocation(30, 30);
		printButton.setVisible(true);
		
		this.add(printButton);
	}
	

	/* (non-Javadoc)
	 * @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
	 */
	@Override
	protected void paintComponent(Graphics g) {
		// TODO Auto-generated method stub
		super.paintComponent(g);
		PageFormat pf = new PageFormat();
		
		
		//g.drawRect((int)pf.getImageableX(), (int)pf.getImageableY(), (int)pf.getImageableWidth()+120, (int)pf.getImageableHeight());
		g.setColor(Color.WHITE);
		g.fillRect((int)pf.getImageableX(), (int)pf.getImageableY(), (int)pf.getImageableWidth()+120, (int)pf.getImageableHeight());
		g.setColor(Color.BLACK);
		
		try {
			if(bj == null)
				bj.print(g, pf, 0);
			else
				bj.print(g, pf, 0);
		} catch (PrinterException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
	
}
